<style>
body {
  overflow-x:hidden;
  white-space:nowrap;

}
*{
  font-family:Arial, Helvetica, sans-serif;
}
a:link, a:visited {
  text-decoration: none;
  color: blue;
}
a:hover, a:active {
  text-decoration:  underline;
}
hr {
  background-color: blue;
  height: 1px;
  border: none;
}
</style>
<body>
<span id="page">
	
</span>
</body>

<script>
var TLD = localStorage["hotel"];
//Debug: Uncomment the line below to get an alert with the hotel TLD
//alert(TLD);
function loadxml(url)
{
	var xmlhttp = new window.XMLHttpRequest();
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	return xmlhttp.responseXML.documentElement;
}
var xml_me = loadxml('http://www.habbo' + TLD + '/toolbar/me');
var xml_friends = loadxml('http://www.habbo' + TLD + '/toolbar/friends');
var xml_community = loadxml('http://www.habbo' + TLD + '/toolbar/community');
var xml_count = loadxml('http://www.habbo' + TLD + '/habbo_count_xml');

var totalonline = xml_count.getElementsByTagName("usercount")[0].childNodes[0].nodeValue;
var MyHabbo = xml_me.getElementsByTagName("URL")[0].childNodes[0].nodeValue;
var newmail = xml_me.getElementsByTagName("CAPTION")[1].childNodes[0].nodeValue;
var newmail_icon = xml_me.getElementsByTagName("ICON_URL")[1].childNodes[0].nodeValue;
var online = xml_friends.getElementsByTagName("CAPTION")[1].childNodes[0].nodeValue;
var online_icon = xml_friends.getElementsByTagName("ICON_URL")[1].childNodes[0].nodeValue;
//document.getElementById("totalonline").innerHTML = totalonline + " Members online";
var offline = xml_friends.getElementsByTagName("CAPTION")[2].childNodes[0].nodeValue;
//document.getElementById("totalonline").innerHTML = totalonline + " Members";
var offline_icon = xml_friends.getElementsByTagName("ICON_URL")[2].childNodes[0].nodeValue;
var requests = xml_friends.getElementsByTagName("CAPTION")[3].childNodes[0].nodeValue;
var requests_icon = xml_friends.getElementsByTagName("ICON_URL")[3].childNodes[0].nodeValue;

var MENUS = xml_me.getElementsByTagName("MENU");
if (MENUS.length >= 2)
{
  var items = MENUS[1].getElementsByTagName("CAPTION")[0];
  items = items.childNodes[0].nodeValue;
  //alert(items);
}
/*****************
 *     Pages     *
 *****************/
function mainmenu()
{
	// Show the main menu
	document.getElementById('page').innerHTML = '<a href="http://habbo.com.au/" target="_blank">' + 
	'<span id="totalonline"></span></a><br />' + 
	'<hr />' + 
	'<a href="mail.html" onclick="JavaScript:loadmail()">' + 
	'	<img id="newmail_icon" src="" width="16" height="16" />' + 
	'	<span id="newmail"></span><br />' + 
	'</a>' + 
	'<hr />' + 
	'<a href="" target="_blank" id="online_url">' + 
	'	<img id="online_icon" src="" width="16" height="16" />' + 
	'	<span id="online"></span>' + 
	'</a><br />' + 
	'<a href="" target="_blank" id="offline_url">' + 
	'	<img id="offline_icon" src="" width="16" height="16" />' + 
	'	<span id="offline"></span>' + 
	'</a><br />' + 
	'<a href="" target="_blank" id="requests_url">' + 
	'	<img id="requests_icon" src="" width="16" height="16" />' + 
	'	<span id="requests"></span>' + 
	'</a><br />' + 
	'<hr />' + 
	'<span id="myhabbo">My Habbo</span><br />' + 
	'<span id="myhome">My Home</span><br />' + 
	'<a href="" onclick="JavaScript:hotgroups()">' + 
	'	<span id="HotGroups">Hot Groups</span>' + 
	'</a><br />' + 
	'<a href="" onclick="JavaScript:hottopics()">' + 
	'	<span id="HotTopics">Hot Topics</span>' + 
	'</a><br />' + 
	'<span id="News">News</span><br />';
	
	// show text
	document.getElementById("totalonline").innerHTML = totalonline + " Members online";
	document.getElementById("newmail").innerHTML = newmail;
	document.getElementById("online").innerHTML = online;
	document.getElementById("offline").innerHTML = offline;
	document.getElementById("requests").innerHTML = requests;

	document.getElementById("online_url").href = MyHabbo;
	document.getElementById("offline_url").href = MyHabbo;
	document.getElementById("requests_url").href = MyHabbo;

	// show icons
	document.getElementById("newmail_icon").src=newmail_icon;
	document.getElementById("online_icon").src=online_icon;
	document.getElementById("offline_icon").src=offline_icon;
	document.getElementById("requests_icon").src=requests_icon;
}
function loadmail()
{
	var menu = xml_me.getElementsByTagName("MENU")[1];
	var menuitems = menu.getElementsByTagName("MENU_ITEM");

	document.getElementById('page').innerHTML = '<center><strong>New Mail</strong></center>';
	// newmail.substring(0,newmail.length-10)-1 works out the number of new mail (subtracts 1 at the end as we count from 0)
	for (i=0;i<=newmail.substring(0,newmail.length-10)-1;i++) // need to loop through the amount of new mail
	{
		document.getElementById('page').innerHTML += '<a target="_blank" href="' + 
			menuitems[i].getElementsByTagName("URL")[0].childNodes[0].nodeValue +
			'"><img src="' + menuitems[i].getElementsByTagName("ICON_URL")[0].childNodes[0].nodeValue + '" />' +
			menuitems[i].getElementsByTagName("CAPTION")[0].childNodes[0].nodeValue + '</a><br />';
	}
	document.getElementById('page').innerHTML += '<a href="" onclick="JavaScript:mainmenu()">[Back Button]</a>';
}
function hotgroups()
{
	var menu = xml_community.getElementsByTagName("MENU")[1];
	var menuitems = menu.getElementsByTagName("MENU_ITEM");

	document.getElementById('page').innerHTML = '<center><strong>Hot Groups</strong></center>';
	for (i=0;i<=9;i++)
	{
		document.getElementById('page').innerHTML += '<a target="_blank" href="' + 
			menuitems[i].getElementsByTagName("URL")[0].childNodes[0].nodeValue +
			'"><img src="' + menuitems[i].getElementsByTagName("ICON_URL")[0].childNodes[0].nodeValue + '" />' +
			menuitems[i].getElementsByTagName("CAPTION")[0].childNodes[0].nodeValue + '</a><br />';
	}
	document.getElementById('page').innerHTML += '<a href="" onclick="JavaScript:mainmenu()">[Back Button]</a>';
}
function hottopics()
{
	var menu = xml_community.getElementsByTagName("MENU")[2];
	var menuitems = menu.getElementsByTagName("MENU_ITEM");

	document.getElementById('page').innerHTML = '<center><strong>Hot Topics</strong></center>';
	for (i=0;i<=9;i++)
	{
		document.getElementById('page').innerHTML += '<a target="_blank" href="' + 
			menuitems[i].getElementsByTagName("URL")[0].childNodes[0].nodeValue +
			'"><img src="' + menuitems[i].getElementsByTagName("ICON_URL")[0].childNodes[0].nodeValue + '" />' +
			menuitems[i].getElementsByTagName("CAPTION")[0].childNodes[0].nodeValue + '</a><br />';
	}
	document.getElementById('page').innerHTML += '<a href="" onclick="JavaScript:mainmenu()">[Back Button]</a>';
}
mainmenu();
</script>
